package com.itheima.dubbo.service.impl;

import com.itheima.dubbo.UserInterface;
import com.itheima.dubbo.pojo.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.rpc.RpcContext;


@DubboService(version ="2.0.0",timeout = 3000,retries = 0)
public class UserServiceImpi implements UserInterface {

    @Override
    public String sayHello(String username) {
//        System.out.println("start:" + new Date());
//        try {
//            Thread.sleep(3000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        System.out.println("end" + new Date());
        System.out.println("version...2.0.0");
        return "Hello Dubbo"+username;
    }

    @Override
    public User findOne(Long id) {
        User user = new User();
        user.setUsername("张三");
        user.setAge(18);
        user.setId(id);
//        String company = RpcContext.getContext().getAttachment("company");
//        System.out.println(company);
//        int i = 1 / 0;
        return user;
    }
}
